
var app = new Vue({
	el: '#app',
	extends:isLogin,
	components: {
		headers: header,
		navs:nav,
		footers:footer,
		login:login,
	},
	data: {
        bgImg:'img/PCindex/top1.jpg',
		navState:'行业动态',
		recent_news: '', //最新动态
		sliderPhoto: '', //轮播图
		policyInfoList: '', //政策资讯列表
		policyInfoList1: '', //政策资讯第一条
		policyInfoList2: [], //政策资讯其余
		weekHotList:'',//本周热点
		topLine:''//头条信息
	},
	methods: {
		//header组件的搜索方法
		searchHeader: function(searchCtx) {
			
		},
		//显示和隐藏右侧边栏
		showNewsList: function(event) {
			$(event.target).parents('.newsList').find('.showNewsList').toggle(300);
		},
		//获取最新动态/政策资讯
		getData: function() {
			var _this = this;
			var method = 'News/GetNewsTitle';
			var param = {
				id: '',
				ColumnID: '',
				ListCount: '4', //获取数量
				PageIndex: '',
				IsShowPhoto: false
			};
			xq.getUrl(method, param, function(res) {
				if(res.data) {
					_this.recent_news = res.data;
				}
			})
		},
		//获取头条
		getTopLine: function() {
			var _this = this;
			var method = 'News/GetTopLine';
			var param = {
				id: '',
				ColumnID: '',
				ListCount: '1', //获取数量
				PageIndex: '',
				IsShowPhoto: false
			};
			xq.getUrl(method, param, function(res) {
				if(res.data) {
					_this.topLine = res.data;
				}
			})
		},
		//获取新闻图片
		getPhoto: function() {
			var _this = this;
			var method = 'News/GetSlidePhoto';
			var param = {
				GetCount: 3,
				Position: 4,
			};
			xq.getUrl(method, param, function(res) {
				if(res.data) {
					var data = res.data;
					for(var i = 0; i < data.length; i++) {
						if(data[i].PicPath.indexOf('http://') == -1) {
							data[i].PicPath = xq.httpUrl + data[i].PicPath;
						}
					}
					_this.sliderPhoto = res.data;
					Vue.nextTick(function() {
						var swiper = new Swiper('.swiper-container', {
							pagination: '.swiper-pagination',
							autoplay: 3000,
						});
					});
				}
			})
		},
		//获取政策资讯
		getPolicyInfoList: function() {
			var _this = this;
			var method = 'News/GetNewList';
			var param = {
				id: '',
				ColumnID: '',
				ListCount: '3', //获取数量
				PageIndex: '',
				IsShowPhoto: true
			};
			xq.getUrl(method, param, function(res) {
				if(res.data) {
					_this.policyInfoList = res.data;
					var data = res.data;
					for(var i = 0; i < data.length; i++) {
						if(i == 0) {
							if(data[i].PicPath && data[i].PicPath.indexOf('http://') == -1){
								data[i].PicPath = xq.imgUrl + data[i].PicPath;
								_this.policyInfoList1 = data[i];
							}else{
								_this.policyInfoList1 = data[i];
							}
						}else{
							_this.policyInfoList2.push(data[i]);
						}
					}
				}
			})
		},
		//获取本周热点
		getWeekHot:function(){
			var _this = this;
			var method = 'News/GetWeekHot';
			var param = {
				id: '',
				ColumnID: '',
				ListCount: '4', //获取数量
				PageIndex: '',
				IsShowPhoto: false
			};
			xq.getUrl(method, param, function(res) {
				if(res.data) {
					_this.weekHotList = res.data;
				}
			})
		},
		//跳转新闻详情文章
		toDetailMsg: function(id) {
			var Url = 'newsDetail.html?id='+id;
			window.open(Url,'_blank');
		},
		//跳转新闻列表页
		toArticleList: function(id) {
			var Url = 'newsList.html?id='+id;
			window.open(Url,'_self');
		},
	},
	mounted: function() {
		this.getData();
		this.getPhoto();
		this.getPolicyInfoList();
		this.getWeekHot();
		this.getTopLine();
	},
	updated: function() {

	}
})